﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Passion3DProject.src.About_the_Camera
{
    class Camera
    {
        #region Atributes
        /// <summary>
        /// Placa de Vídeo
        /// </summary>

        private Matrix worldCamMatrix;
        /// <summary>
        /// matriz de "Mundo da Câmera. Sua Posição no espaço
        /// </summary>
        public Matrix WorldCamMatrix { get { return this.worldCamMatrix; } set { this.worldCamMatrix = value; } }
        private float rotationX;
        /// <summary>
        /// Rotação do Objeto
        /// </summary>
        public float RotationX { get { return this.rotationX; } set { this.rotationX = value; } }

        private float rotationY;
        /// <summary>
        /// Rotação do Objeto
        /// </summary>
        public float RotationY { get { return this.rotationY; } set { this.rotationY = value; } }

        private float rotationZ;
        /// <summary>
        /// Rotação do Objeto
        /// </summary>
        public float RotationZ { get { return this.rotationZ; } set { this.rotationZ = value; } }
        private bool isReady = true;
        /// <summary>
        /// Estado da câmera.
        /// </summary>
        public bool IsReady { get { return this.isReady; } set { this.isReady = value; } }

        private float cameraGapAngle;
        /// <summary>
        /// Ângulo de abertura Câmera;
        /// </summary>
        public float CameraGapAngle
        {
            get
            {
                return this.cameraGapAngle;
            }
            set
            {
                this.cameraGapAngle = MathHelper.ToRadians(value);
            }
        }

        private Vector3 target;
        /// <summary>
        /// Alvo da Câmera
        /// </summary>
        public Vector3 Target { get { return this.target; } set { this.target = value; } }

        private Matrix rotationMatrix;
        /// <summary>
        /// Rotação da Câmera
        /// </summary>
        public Matrix RotationMatrix
        {
            get { return rotationMatrix; }
            set { rotationMatrix = value; }
        }

        private Vector3 orientation;
        /// <summary>
        /// Orientação da Câmera
        /// </summary>
        public Vector3 Orientation { get { return this.orientation; } set { this.orientation = value; } }

        private Matrix projectionCamMatrix;
        /// <summary>
        /// Matriz de Projeção da Câmera
        /// </summary>
        public Matrix ProjectionCamMatrix { get { return this.projectionCamMatrix; } set { this.projectionCamMatrix = value; } }

        private Matrix cameraViewMatrix;
        /// <summary>
        /// Matrix View da Câmera
        /// </summary>
        public Matrix viewMatrix
        {
            get
            {
                return this.cameraViewMatrix;
            }
            set
            {
                this.cameraViewMatrix = value;
            }
        }

        private float aspectRatio;
        /// <summary>
        /// Resolução da Tela
        /// </summary>
        public float AspectRatio { get { return this.aspectRatio; } set { this.aspectRatio = value; } }

        private Vector3 cameraPosition;
        /// <summary>
        /// Posição da Câmera
        /// </summary>
        public Vector3 Position
        {
            get
            {
                return this.cameraPosition;
            }
            set
            {
                if (!(Position.Y < 1.5f))
                {
                    this.cameraPosition = value;
                }
                else
                {
                    this.cameraPosition.X = value.X;
                    this.cameraPosition.Z = value.Z;
                    this.cameraPosition.Y = value.Y;
                }
            }
        }

        private Vector3 playerDistance;
        /// <summary>
        /// Representa o quão distante a câmera está do jogador (para "trás" e para "cima")
        /// </summary>
        public Vector3 PlayerDistance { get { return this.playerDistance; } set { this.playerDistance = value; } }

        private Vector3 targetDistance;
        /// <summary>
        /// Representa o quão distante o alvo da câmera está do jogador (para "cima")
        /// </summary>
        public Vector3 TargetDistance { get { return targetDistance; } set { targetDistance = value; } }
        /// <summary>
        /// Distancia mínima para que a placa de vídeo possa renderizar os objetos
        /// </summary>

        float nearestDistance;
        /// <summary>
        /// Distância máxima para que a Placa de vídeo renderize os objetos
        /// </summary>
        public float NearestDistance { get { return this.nearestDistance; } set { this.nearestDistance = value; } }
        float maxDistance;
        /// <summary>
        /// Velocidade de movimento da câmera
        /// </summary>
        public float MaxDistance { get { return this.maxDistance; } set { this.maxDistance = value; } }
        private const float cameraSpeed = 30.0f;
        /// <summary>
        /// Velocidade de rotação da Câmera
        /// </summary>
        private const float cameraRotationSpeed = 0.3f;

        #endregion

        #region Methods
        public Camera()
        {
        }

        public Camera(GraphicsDeviceManager ghpcs)
        {
        }
        #endregion
    }
}
